﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Sunny.UI.UITextBox;

namespace NovoSerDes
{
    public partial class CusUIEdit : UIEdit
    {
        private UITextBox.UIEditType _uiEditType;
        private int decLength = 0;

        public CusUIEdit()
        {
        
        }

        public new UITextBox.UIEditType Type
        {
            get
            {
                return _uiEditType;
            }
            set
            {
                if (_uiEditType == value)
                {
                    return;
                }

                _uiEditType = value;
                switch (_uiEditType)
                {
                    case UITextBox.UIEditType.Double:
                        if (!CanEmpty && !Text.IsDouble())
                        {
                            Text = 0.ToString("f" + decLength);
                        }

                        break;
                    case UITextBox.UIEditType.Integer:
                        if (!CanEmpty && !Text.IsInt())
                        {
                            Text = "0";
                        }

                        break;
                    case UITextBox.UIEditType.String:
                        Text = "";
                        break;
                }

                CheckMaxMin();
                if (base.DesignMode)
                {
                    Invalidate();
                }
            }
        }
    }
}
